# %%

segpkl_files_page = """
2023-05-06_14-40-17CWxDB
2023-05-06_14-59-04CBxDW
2023-05-06_16-12-16GWxHB
2023-05-06_16-31-07GBxHW
2023-05-09_15-41-21CBxGW
2023-05-09_16-01-27CWxGB
2023-05-09_16-21-19DWxHB
2023-05-09_16-40-53DBxHW
2023-05-10_13-57-09CWxDB
2023-05-10_14-15-48CBxDW
2023-05-10_14-43-45GWxHB
2023-05-10_15-29-06GBxHW
2023-05-13_15-41-03GWxCB
2023-05-13_16-18-15HWxDB
2023-05-13_15-59-40GBxCW
2023-05-13_16-36-27HBxDW
2023-07-24_13-58-48CwxDb
2023-07-24_14-19-10CbxDw
2023-07-24_14-37-09GwxHb
2023-07-24_14-56-29GbxHw
2023-07-25_14-00-26CwxHb
2023-07-25_14-20-01CbxHw
2023-07-25_14-38-46DbxGw
2023-07-25_14-58-31DwxGb
2023-07-26_14-14-04GwxHb
2023-07-26_14-33-39GbxHw
2023-07-26_14-52-07CwxDb
2023-07-26_15-11-08CbxDw
2023-07-27_13-56-43DbxHw
2023-07-27_14-17-11DwxHb
2023-07-27_14-37-10CwxGb
2023-07-27_14-56-29CbxGw
2023-06-25_13-30-56Aw1xCb1
2023-06-25_13-50-16Aw2xCb3
2023-06-25_14-16-26Bw3xDb2
2023-06-25_14-42-59Bw4xDb4
2023-06-25_15-06-49Ew3xGb4
2023-06-25_15-28-12Ew4xGb1
2023-06-25_16-05-05Fw1xHb3
2023-06-25_16-25-50Fw2xHb2
2023-06-26_13-31-16Ew3xCb2
2023-06-26_13-51-20Ew4xCb3
2023-06-26_14-12-12Fw2xDb2
2023-06-26_14-32-38Fw1xDb4
2023-06-26_14-51-40Aw2xGb1
2023-06-26_15-13-37Aw1xGb4
2023-06-26_15-34-53Bw4xHb3
2023-06-26_15-56-01Bw3xHb2
2023-06-27_13-36-48Ew3xHb3
2023-06-27_13-55-26Ew4xHb2
2023-06-27_14-16-49Fw2xGb4
2023-06-27_14-37-53Fw1xGb1
2023-06-27_15-02-32Aw2xDb2
2023-06-27_15-26-30Aw1xDb4
2023-06-27_15-48-23Bw4xCb3
2023-06-27_16-10-28Bw3xCb2
2023-06-28_13-39-57Cb3xFw1
2023-06-28_13-59-29Db1xEw4
2023-06-28_14-25-50Db4xEw3
2023-06-28_14-46-32Cb2xFw2
2023-06-28_15-06-34Aw1xHb3
2023-06-28_15-26-09Bw4xGb4
2023-06-28_15-57-19Bw1xGb3
2023-06-28_16-19-17Aw2xHb2
2023-05-24_14-43-58CBxDW
2023-05-24_15-04-30CWxDB
2023-05-24_16-19-14GBxHW
2023-05-24_16-40-04GWxHB
2023-05-28_14-05-40GBxCW
2023-05-28_14-25-37GWxCB
2023-05-28_14-46-14HBxDW
2023-05-28_15-05-01HWxDB
2023-05-29_13-59-55GBxHW
2023-05-29_14-18-03GWxHB
2023-05-29_16-07-57CWxDB
2023-05-29_16-29-44CBxDW
2023-06-01_15-07-10CBxGW
2023-06-01_15-31-23CWxGB
2023-06-01_15-51-23DWxHB
2023-06-01_16-11-57DBxHW
2023-07-19_14-03-20Aw1xCb1
2023-07-19_14-21-37Aw2xCb3
2023-07-19_14-43-23Bw3xDb2
2023-07-19_15-03-39Bw4xDb4
2023-07-19_15-23-57Ew4xGb1
2023-07-19_15-52-15Fw2xHb3
2023-07-19_16-12-27Fw1xHb2
2023-07-20_14-02-22Ew4xHb3
2023-07-20_14-22-22Fw2xGb4
2023-07-20_14-49-29Fw1xGb1
2023-07-20_15-12-07Aw1xDb4
2023-07-20_15-33-43Aw2xDb2
2023-07-20_15-54-56Bw4xCb1
2023-07-20_16-18-51Bw3xCb3
2023-07-21_14-00-45Aw1xGb1
2023-07-21_14-20-55Aw2xGb4
2023-07-21_14-41-27Bw3xHb2
2023-07-21_15-02-56Bw4xHb3
2023-07-21_15-23-20Ew4xCb3
2023-07-21_15-46-50Fw1xDb2
2023-07-21_16-07-47Fw2xDb4
2023-07-22_14-00-17Ew4xDb4
2023-07-22_14-20-01Fw1xCb1
2023-07-22_14-44-43Fw2xCb3
2023-07-22_15-04-44Aw1xHb2
2023-07-22_15-23-30Aw2xHb3
2023-07-22_15-43-10Bw3xGb4
2023-07-22_16-11-25Bw4xGb1
2023-06-13_14-00-23CWxDB
2023-06-13_14-20-17CBxDW
2023-06-13_14-39-39GWxHB
2023-06-13_14-59-07GBxHW
2023-06-14_14-05-34GBxCW
2023-06-14_14-24-04GWxCB
2023-06-14_14-43-00HWxDB
2023-06-14_15-01-35HBxDW
2023-06-15_14-08-01GWxHB
2023-06-15_14-27-06GBxHW
2023-06-15_14-47-25CBxDW
2023-06-15_15-06-35CWxDB
2023-06-16_14-02-00HBxDW
2023-06-16_14-20-23HWxDB
2023-06-16_14-47-33GWxCB
2023-06-16_15-07-10GBxCW
"""
segpkl_files = [s for s in segpkl_files_page.split("\n") if len(s)]

# %%
import os.path as osp
import numpy as np

segpkl_nakes = [osp.splitext(osp.basename(f))[0] for f in segpkl_files]
animals_pair = [f[19:] for f in segpkl_nakes]
animals = [f.split("x") for f in animals_pair]
animals_sort = [((a[0], a[1]) if a[0][-1] in "Bb" else (a[1], a[0])) for a in animals]

prefix = "230630"
for (rb, rw) in animals_sort:
    rb = prefix + rb[:-1].upper() + rb[-1].lower()
    rw = prefix + rw[:-1].upper() + rw[-1].lower()
    print("\t".join([rb, rw]))

animals_bw = np.array([[a[0][0], a[1][0]] for a in animals_sort])
out_voxel = np.zeros(animals_bw.shape, dtype=int)
out_voxel[np.isin(animals_bw, ["A", "B", "C", "D"])] = 260
out_voxel[np.isin(animals_bw, ["E", "F", "G", "H"])] = 240

for (v0, v1), f in zip(out_voxel, segpkl_files):
    print(v0, v1, f)
